package com.hsmpay.mobile.service.terminal.impl;

import com.hsmpay.common.service.impl.BaseServiceSupport;
import com.hsmpay.mobile.dao.terminal.TerminalPrivilegesDao;
import com.hsmpay.mobile.pojo.terminal.TerminalPrivileges;
import com.hsmpay.mobile.service.terminal.TerminalPrivilegesService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;


/**
 * 终端功能清单 服务类接口 terminalPrivilegesService
 * 对应Dao terminalPrivilegesDao
 *
 * @param <Entity>
 * @param <Query>
 * @author 颜铃璋
 *         创建时间： 2012-12-18
 */
@Service("terminalPrivilegesService")
public class TerminalPrivilegesServiceImpl extends BaseServiceSupport<TerminalPrivileges, Long> implements TerminalPrivilegesService<TerminalPrivileges, Long> {
    @Resource(name = "terminalPrivilegesDao")
    private TerminalPrivilegesDao<TerminalPrivileges, Long> terminalPrivilegesDao;

    /**
     * 根据功能关键字 返回功能可不可用
     *
     * @param functionKey
     * @return
     * @throws Exception
     */
    public TerminalPrivileges checkPrivilegesIsValid(String functionKey) throws Exception {
        return terminalPrivilegesDao.checkPrivilegesIsValid(functionKey);
    }

    /**
     * 根据功能关键字 查询功能
     *
     * @param functionKey
     * @return
     * @throws Exception
     */
    public TerminalPrivileges searchPrivilegesByFunctionKey(String functionKey) throws Exception {
        TerminalPrivileges param = new TerminalPrivileges();
        param.setFunctionKey(functionKey);
        return terminalPrivilegesDao.searchEntity(param);
    }

    @Override
    public List<TerminalPrivileges> searchVisibleFunctions() throws Exception {
        TerminalPrivileges param = new TerminalPrivileges();
        param.setVisible(1L);

        return terminalPrivilegesDao.searchEntityList(param);
    }

}
